const Service = require('egg').Service;

class ArticleService extends Service {
   async create(params) {
       const { app } = this;
       try {
           const result = await app.mysql.insert('article', params);
           return result;
       } catch (e) {
           console.log(e);
           return null;
       }

    }
    async lists() {
       const { app } = this;
        try {
            const result = await app.mysql.select('article');
            return result;
        } catch (e) {
            console.log(e);
            return null;
        }
    }
    async details(id) {
        const { app } = this;
        try {
            const result = await app.mysql.get('article', { id });
            return result;
        } catch (e) {
            console.log(e);
            return null;
        }
    }

}

module.exports = ArticleService;
